using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraSplashScreen;

namespace Comteck.Winforms {
  /// <summary>
  /// 登录等待界面
  /// https://www.devexpress.com/Support/Center/Question/Details/Q283053/how-to-specify-a-background-image-for-the-splashscreen
  /// </summary>
  public partial class FrmLoadWaitScreen : SplashScreen {

    /// <summary>
    /// 
    /// </summary>
    public FrmLoadWaitScreen() {
      InitializeComponent();
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void FrmLoadWaitScreen_Load(object sender, EventArgs e) {
      if (this.DesignMode) {
        return;
      }

      this.AddDragEvents();
      //this.pictureEdit2.AddDragEvents();
    }

    /// <summary>
    /// 发送命令
    /// </summary>
    /// <param name="cmd"></param>
    /// <param name="arg"></param>
    public override void ProcessCommand(Enum cmd, object arg) {
      base.ProcessCommand(cmd, arg);

      var command = (LoadWaitScreenCommand) cmd;

      switch (command) { 
        case LoadWaitScreenCommand.ChangeTitle:
          // 改变标题
          ckTitle.Text = arg as string;
          break;
        case LoadWaitScreenCommand.SetProgress:
          // 进度条
          ckProgressBarControl.Tag = (int)arg;
          break;
        default:
          break;
      }
    }
  }

  /// <summary>
  /// 加载界面命令
  /// </summary>
  public enum LoadWaitScreenCommand {
    /// <summary>
    /// 改价进度条
    /// </summary>
    SetProgress = 0,

    /// <summary>
    /// 改变标题
    /// </summary>
    ChangeTitle = 1,
  }

}
